/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package controller;

import controller.service.UserControllerService;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import model.dao.UserDAO;
import model.dao.service.UserDAOService;
import model.entities.User;

/**
 *
 * @author K u Ku
 */
public class UserController implements UserControllerService {

    private static UserController userCtrl;
    public static UserController getInstance(){
        if(userCtrl==null){
            userCtrl = new UserController();
        }
        return userCtrl;
    }
    
    UserDAOService serviceDao = UserDAO.getInstance();
    
    @Override
    public List<User> getUsersList() {
        return serviceDao.getUsersList();
    }

    @Override
    public User getUserByID(int userID) {
        return serviceDao.getUserByID(userID);
    }

    @Override
    public boolean insertUser(User user) {
        return serviceDao.insertUser(user);
    }

    @Override
    public boolean updateUser(User user) {
        return serviceDao.updateUser(user);
    }

    @Override
    public boolean deleteUser(int userID) {
        return serviceDao.deleteUser(userID);
    }

    @Override
    public List<User> findUserByID(int id) {
        return serviceDao.findUserByID(id);
    }

    @Override
    public List<User> findUserByName(String name) {
        return serviceDao.findUserByName(name);
    }

    @Override
    public boolean login(String userName, String password) {
        return serviceDao.login(userName, password);
    }

    @Override
    public void logout() {
        serviceDao.logout();
    }

    @Override
    public User getUserByUserName(String userName) {
        return serviceDao.getUserByUserName(userName);
    }
 
}
